package com.quan.system.scheduler;

import com.quan.commons.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * 测试定时任务
 */
@Slf4j
@Component
public class TestSchedulerJob implements Job, Serializable {

    private static final long serialVersionUID = 1L;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDetail jobDetail = context.getJobDetail();

        log.info("==>开始执行任务【{}】：{}, {}",
                jobDetail.getKey(),
                DateUtils.getDateTime(),
                jobDetail.getJobClass());

        // JobDataMap数据
        Set<Entry<String, Object>> entrySet = jobDetail.getJobDataMap().entrySet();
        for (Entry<String, Object> entry : entrySet) {
        	log.info("参数：key=>{}, value=>{}", entry.getKey(), entry.getValue());
        }

    }
}
